import random
n = random.randint(0,10)
i = 0
r = False

while r == False:
    try:
        c = int(input('请输入所猜数字(0~10)'))
        i = i+1
        if c > n:
            print('遗憾，太大了')
        elif c < n :
            print('遗憾，太小了')
        elif c == n:
            print('恭喜你{}次猜中了'.format(i))
            r = True
    except ValueError:
        print('输入非整数')
